<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link rel="shortcut icon" href="__IMG__/favicon.ico" />
		<link rel="bookmark" href="__IMG__/favicon.ico" type="image/x-icon" 　/>
		<title>充值</title>
		<link rel="stylesheet" type="text/css" href="__CSS__/mui.min.css"/>
		<link rel="stylesheet" type="text/css" href="__CSS__/common.css"/>
		<link rel="stylesheet" type="text/css" href="__CSS__/index.css"/>
		<script src="__JS__/mui.min.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript" charset="utf-8">
	      	mui.init();
        </script>
        <style type="text/css">
        	input{
        		margin: 0;
        	}
        	.put{
        		width: 100px;
        		height: 100px;
        		background: url(__IMG__/iconfont-tianjia.png)no-repeat;
        		background-size:100% 100% ;
        		position: relative;
        		z-index: 10;
            }
            input[type=button]{
            	width: 200px;
            	text-align: center;
            	color: #fff;
            	border: none;
            }
			.next_a{
				width: 200px;
				height: 40px;
				background: url(__IMG__/bg_inp.png)no-repeat;
				background-size:100% 100% ;
				color: #fff;
				line-height: 40px;
				text-align: center;
				margin-top: 20px;
			}
        </style>
	</head>
	<body class="bg_ff">
		<header class="mui-bar mui-bar-nav">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
		    <h1 class="mui-title">充值</h1>
		    <a  class="right sever_box"><img class="width_100 mg_top5" src="__IMG__/icon_service.png" alt="" /></a>
		</header>
		<div class="mui-content bg_ff">
		   <div class="padding_10">
			   <form action="{:url('recharge/offline_charge')}" method="post" onsubmit="return check()">
			   <p>
				   	<label for="">真实姓名：</label>
				   	<input type="text" name="name" id="name"  value="{$true_name|default=''}" />
				    <input type="hidden" name="way" id="way"  value="{$way}" />
			   </p>
			   <p>
				   <label for="">金额：</label>
				   <input type="text" name="money" id="money"  value="" />
			   </p>
			   <p>
			   	    <label for="">备注：</label>
				   	<textarea id="remark" rows="5" cols="30" class="padding_5">{if $way==1}微信{elseif $way==2}支付宝{/if}</textarea>
			   </p>
			   <h6 class="clearfix"><span class="right"><i>0</i>/200</span></h6>
			   <div >
			     	   <span class="file_p text-center" id="btn_logo">
						   <label >回执图片</label>
						   <img height="100px"   id="logo" src="__IMGA__/add-button.jpg"/><br />
						   <input type="hidden" name="hui" id="hui" value=""/>
						</span>
			   </div>
			   <div>
			   <span class="text-center" style="color: red">
				   (图片上传可能会比较慢，请耐心等待！请勿重复提交)
			   </span>
			   </div>
				   <p class="text-center mg_top40">
					   <a href="#" id="tj" class="next_a">提交</a>
				   </p>
			   </form>
		   </div>
		</div>
	</body>
	<script src="__JSA__/jquery-1.10.2.min.js"></script>
	<script type="text/javascript" src="__JSA__/Plupload/plupload.full.min.js"></script>
	<script type="text/javascript">

        var ids = new Array("btn_logo");

        $.each(ids,function(i,n){

            var self = this.toString();

            var uploader_avatar = new plupload.Uploader({

                runtimes: 'gears,html5,html4,silverlight,flash', //上传插件初始化选用那种方式的优先级顺序

                browse_button: self, // 上传按钮

                url: "{:url('upload_one')}", //远程上传地址

                flash_swf_url: '__DTSC__/Moxie.swf',//flash文件地址

                silverlight_xap_url: '__DTSC__/Moxie.xap', //silverlight文件地址

                filters: {

                    max_file_size: '100mb', //最大上传文件大小（格式100b, 10kb, 10mb, 1gb）

                    mime_types: [//允许文件上传类型

                        {title: "files", extensions: "jpg,png,gif,jpeg"}

                    ]

                },

                multi_selection: false, //true:ctrl多文件上传, false 单文件上传

                init: {

                    FilesAdded: function(up, files) { //文件上传前

                        uploader_avatar.start();

                    },

                    UploadProgress: function(up, file) { //上传中，显示进度条

                        var percent = file.percent;

                        $("#" + file.id).find('.bar').css({"width": percent + "%"});

                        $("#" + file.id).find(".percent").text(percent + "%");

                    },

                    FileUploaded: function(up, file, info) { //文件上传成功的时候触发

                        var data = eval("(" + info.response + ")");//解析返回的json数据

                        if(data.status == 1){

                            document.getElementById('logo').src = data.pic;

                            $('#hui').val(data.picd);

                        }else{

                            alert(data.error);

                        }

                    },

                    Error: function(up, err) { //上传出错的时候触发

                        alert(err.message);

                    }

                }

            });

            uploader_avatar.init();

        });

	</script>
    <script>
		$('#tj').click(function () {
            var name     = $('#name').val();
            var money    = $('#money').val();
            var hui      = $('#hui').val();
            var remark   = $('#remark').val();
            var way      = $('#way').val();
            if(name==""){
                alert('请填写真实姓名');
                return false;
            }
            if(money==""){
                alert('请填写充值金额');
                return false;
            }
            if(hui==""){
                alert('请填写回执图片');
                return false;
            }
            $.ajax({
                type: "post",
                url: "{:url('recharge/offline_charge')}",
                data: {
                    "name": name,
                    'remark': remark,
                    'money': money,
                    'hui': hui,
					'way':way
                },
                dataType: "json",
                async: false,
                success: function(data) {
                    var ret = data.ret;
                    var msg = data.msg;
                    if(ret=='200'){
                        alert(msg);
                        location.href="{:url('mine/index')}";
					}else{
                        alert(msg);
					}
                }
            });
        })

    </script>
</html>
